package com.csthink.utils;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.IOException;

/**
 * @author <a href="mailto:csthink@icloud.com">Mars</a>
 * @since 2024-04-12 17:04
 */
public class FileUtils {

    public static void deleteIfExists(Configuration conf, String fileName) throws IOException {
        FileSystem fileSystem = FileSystem.get(conf);

        Path path = new Path(fileName);
        if (fileSystem.exists(path)) {
            fileSystem.delete(path, true);
        }
    }
}
